package com.minsheng.epidemic_rep.service;

import com.minsheng.epidemic_rep.util.GenerateCsv;
import com.minsheng.epidemic_rep.util.ZipUtil;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.List;

/**
 * @Classname ScheduledService
 * @Description 定时任务
 * @Date 2020/9/27 9:51
 * @Created by You
 */
@Service
public class ScheduledService {

//    @Scheduled(cron = "0 40 16 * * ?")
    public void createCsv(){
//-------------------------------------压缩ZIP文件
        //获取待压缩文件列表(文件具体路径)
        List<String> pathList = ZipUtil.getFile("d:/frmzsj/",0);

        try {
            ZipUtil.zipFiles(pathList,"d:/frsjzip/发热门诊数据.zip");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    //定时清空目录
//    @Scheduled(cron = "59 59 23 * * ?")
    public void delcsv() {
        List<String> pathList = ZipUtil.getFile("d:/frmzsj/",0);
        try {
            GenerateCsv.deleteFiles(pathList);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
